package com.mail.server.controller;


import com.mail.model.db.CmsSubject;
import com.mail.model.vo.MyPage;
import com.mail.server.common.R;
import com.mail.server.service.CmsSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 专题表 前端控制器
 * </p>
 * @author WJZ
 * @since 2022-06-20
 */
@RestController
@RequestMapping("/subject")
public class CmsSubjectController {

	@Autowired
	private CmsSubjectService cmsSubjectService;

	/**
	 * 获取全部商品专题
	 * 接口地址:/subject/listAll
	 * @return
	 */
	@GetMapping("/listAll")
	private R<List<CmsSubject>> listAll(){
		List<CmsSubject> cmsSubjects = cmsSubjectService.listAll();
		return R.success(cmsSubjects, "操作成功!");
	}

	/**
	 * 根据专题名称分页获取商品专题(分页查询)
	 * 接口地址:/subject/list
	 * @return
	 */
	@GetMapping("/list")
	public R<MyPage<CmsSubject>> listByPage(@RequestParam(defaultValue = "1") Long pageNum,
											@RequestParam(defaultValue = "10") Long pageSize,
											String keyword){
		MyPage<CmsSubject> myPage = cmsSubjectService.listByPage(pageNum, pageSize, keyword);
		return R.success(myPage, "操作成功!");
	}

}
